package br.ufpi.hu.prescricao.util;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Concentra envios de mensagens ao usuário.
 * 
 * @author Leonardo Sampaio
 * @since 07/12/2012
 *
 */
public class ErrorHelper implements Serializable {
	
	private static final long serialVersionUID = -2992835654220030265L;

	public void sendInfoMessageToUser(String message){
		FacesContext context = getContext();
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
	}

	public void sendErrorMessageToUser(String message){
		FacesContext context = getContext();
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
	}
	
	public void sendWarnMessageToUser(String message){
		FacesContext context = getContext();
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, message, message));
	}


	private FacesContext getContext() {
		FacesContext context = FacesContext.getCurrentInstance();
		return context;
	}

}
